package com.snake.springboot.custom.service.assemble.base;


import com.snake.springboot.custom.api.model.base.CustomModel;
import com.snake.springboot.custom.api.request.base.CustomAdminReq;
import com.snake.springboot.custom.api.request.base.CustomQuery;
import com.snake.springboot.custom.api.request.base.CustomReq;
import com.snake.springboot.custom.dao.mybatis.entity.base.CustomDO;
import org.apache.commons.lang3.StringUtils;
import org.snake.common.code.SerialNumberGeneratorFactory;
import org.snake.common.utils.PropertyUtils;

/**
 * <p>商户组装器
 * 类{@code CustomAssemble} </br>
 * @author yangxt
 * 创建时间2025/2/8 10:42
 */
public class CustomAssemble {
    public static CustomDO customDOAss(CustomReq customReq) {
        CustomDO customDO = new CustomDO();
        customReq.setCustomId(SerialNumberGeneratorFactory.buildId4Bean());
        PropertyUtils.copyProperties(customDO,customReq);
        if (StringUtils.isEmpty(customDO.getCustomName())){
            customDO.setCustomName(customDO.getAccountName());
        }


        return customDO;
    }

    public static CustomDO customDOAss(CustomAdminReq customReq) {
        CustomDO customDO = new CustomDO();
        PropertyUtils.copyProperties(customDO,customReq);
        return customDO;
    }

    public static CustomDO customDOAss(CustomModel model) {
        CustomDO customDO = new CustomDO();
        PropertyUtils.copyProperties(customDO,model);
        return customDO;
    }
    public static CustomDO customDOAss(CustomQuery query) {
        CustomDO customDO = new CustomDO();
        PropertyUtils.copyProperties(customDO,query);
        return customDO;
    }

}
